Sources : 2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE & Données hospitalières relatives à l’épidémie de COVID-19 par Santé publique France & Fichier des personnes décédées, Institut National de la Statistique et des Etudes Economiques (Insee)
---
title: "Représentation graphique du COVID-2019"
author: "A Gaudet Chardonnet"
date: '`r format(Sys.time(), "%d %B %Y, %H:%M")`'
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, include=FALSE}
library(directlabels)
library(lubridate)
library(tidyverse)
library(ggpmisc)
library(ggrepel)
library(plotly)
library(plyr)
library(flexdashboard)
setwd("/Users/antoinegaudetchardonnet/Git/COVID-19/COVID-19/Data")
baseDCj <- read.csv ("DCjours_annuelV2.csv")
baseDCj$Date <- as.Date (baseDCj$Date)
baseDCj$Deces <- as.numeric (baseDCj$Deces)
baseDCj$Annee <- as.factor (baseDCj$Annee)
baseDCj <- baseDCj[,-1]
baseDCj$cumsum <- do.call(c, tapply(baseDCj$Deces, baseDCj$Annee, FUN=cumsum))
csv <- paste("ptime_series_19-covid-Deaths_",Sys.Date(),".csv", sep="" )
csv2 <- paste("ptime_series_19-covid-Hospit",Sys.Date(),".csv", sep="" )
download.file("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv",
destfile = csv, method = "curl")
download.file("https://www.data.gouv.fr/fr/datasets/r/63352e38-d353-4b54-bfd1-f1b3ee1cabd7",
destfile = csv2, method = "curl")
setwd("/Users/antoinegaudetchardonnet/Git/COVID-19/COVID-19/")
# Base Johns Hopkins CSSE
base <- read.csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv")
# Suppression de la colonne des Provinces
base <- base[base$"Province.State" == "",]
#Creation des data frame à 3 colonnes : nombres DC, date, Pays
#
baseGermany <- base %>%
filter (Country.Region == "Germany")
baseGermany <- baseGermany[,c(-1:-43)]
baseGermany <- as.numeric(baseGermany)
baseItaly <- base %>%
filter (Country.Region == "Italy")
baseItaly <- baseItaly[,c(-1:-43)]
baseItaly <- as.numeric(baseItaly)
baseFrance <- base %>%
filter (Country.Region == "France")
baseFrance <- baseFrance[,c(-1:-43)]
x <- ncol (baseFrance)
baseFrance <- as.numeric(baseFrance)
baseIran <- base %>%
filter (Country.Region == "Iran")
baseIran <- baseIran[,c(-1:-43)]
baseIran <- as.numeric(baseIran)
baseUS <- base %>%
filter (Country.Region == "US")
baseUS <- baseUS[,c(-1:-43)]
baseUS <- as.numeric(baseUS)
baseUK <- base %>%
filter (Country.Region == "United Kingdom")
baseUK <- baseUK[,c(-1:-43)]
baseUK <- as.numeric(baseUK)
basee <- base %>%
filter (Country.Region == "Spain")
basee <- basee[,c(-1:-43)]
basee <- as.numeric(basee)
basen <- base %>%
filter (Country.Region == "Netherlands")
basen <- basen[,c(-1:-43)]
basen <- as.numeric(basen)
baseb <- base %>%
filter (Country.Region == "Brazil")
baseb <- baseb[,c(-1:-43)]
baseb <- as.numeric(baseb)
# creation du Data frame avec la date du 01/03 au jours dernier jour de la abse initiale
df <- data.frame(baseFrance,(as.Date("2020-03-01") + 0:(x-1)),"France", c(1:x))
di <- data.frame(baseItaly,(as.Date("2020-03-01") + 0:(x-1)),"Italie", c(1:x))
dg <- data.frame(baseGermany,(as.Date("2020-03-01") + 0:(x-1)),"Allemagne", c(1:x))
dus <- data.frame(baseUS,(as.Date("2020-03-01") + 0:(x-1)),"US", c(1:x))
duk <- data.frame(baseUK,(as.Date("2020-03-01") + 0:(x-1)),"UK", c(1:x))
dir <- data.frame(baseIran,(as.Date("2020-03-01") + 0:(x-1)),"Iran", c(1:x))
de <- data.frame(basee,(as.Date("2020-03-01") + 0:(x-1)),"Espagne", c(1:x))
dn<- data.frame(basen,(as.Date("2020-03-01") + 0:(x-1)),"Pays-Bas", c(1:x))
db <- data.frame(baseb,(as.Date("2020-03-01") + 0:(x-1)),"Bresil", c(1:x))
colnames(df) <- c("dc","Date","Pays","jour")
colnames(di) <- c("dc","Date","Pays","jour")
colnames(dg) <- c("dc","Date","Pays","jour")
colnames(dus) <- c("dc","Date","Pays","jour")
colnames(duk) <- c("dc","Date","Pays","jour")
colnames(dir) <- c("dc","Date","Pays","jour")
colnames(de) <- c("dc","Date","Pays","jour")
colnames(dn) <- c("dc","Date","Pays","jour")
colnames(db) <- c("dc","Date","Pays","jour")
# base des décès journaliers par pays (différence entre le nombre de totale pour chaque journée
dfj <- data.frame(dc = c(0,diff(df$dc)), Date = c(df$Date), Pays = "Journaliers", jour = c(1:x))
dij <- data.frame(dc = c(0,diff(di$dc)), Date = c(di$Date), Pays = "Journaliers", jour = c(1:x))
dukj <- data.frame(dc = c(0,diff(duk$dc)), Date = c(duk$Date), Pays = "yJournaliers", jour = c(1:x))
dusj <- data.frame(dc = c(0,diff(dus$dc)), Date = c(dus$Date), Pays = "yJournaliers", jour = c(1:x))
dgj <- data.frame(dc = c(0,diff(dg$dc)), Date = c(dg$Date), Pays = "Journaliers", jour = c(1:x))
dnj <- data.frame(dc = c(0,diff(dn$dc)), Date = c(dn$Date), Pays = "yJournaliers", jour = c(1:x))
dbj <- data.frame(dc = c(0,diff(db$dc)), Date = c(db$Date), Pays = "Journaliers", jour = c(1:x))
baseIFG <- rbind(di,df,dg, dus, duk,dir,de,dn, db)
# Base Santé publique france
hospit <- read.csv2("https://www.data.gouv.fr/fr/datasets/r/63352e38-d353-4b54-bfd1-f1b3ee1cabd7")
# Suppression de la colonne sexe et mise en forme de la base
hospit <- hospit[hospit$sexe == "0",]
transform(hospit, dep = as.numeric(dep))
transform(hospit, jour = as.Date(jour))
hospit$jour <- as.Date(hospit$jour)
hospitidf <- hospit[hospit$dep == 75 | hospit$dep == 91 |hospit$dep == 92 |hospit$dep == 93 |hospit$dep == 94 |hospit$dep == 95 |hospit$dep == 77 ,]
# hosp = hospitalisation en France
hosp <- data.frame(aggregate(hospit$hosp, by = list(typ2 = hospit$jour), sum),"France")
hospidf <- data.frame(aggregate(hospitidf$hosp, by = list(typ2 = hospitidf$jour), sum), "IdF")
colnames(hosp) <- c("Date","hosp","lieu")
colnames(hospidf) <- c("Date","hosp","lieu")
# data hospitalisation en réa
rea <- data.frame(aggregate(hospit$rea, by = list(typ2 = hospit$jour), sum),"France")
reaidf <- data.frame(aggregate(hospitidf$rea, by = list(typ2 = hospitidf$jour), sum), "IdF")
colnames(rea) <- c("Date","rea","lieu")
colnames(reaidf) <- c("Date","rea","lieu")
# Base Santé publique hospit quotidienne france
incid_hospit <- read.csv2("https://www.data.gouv.fr/en/datasets/r/6fadff46-9efd-4c53-942a-54aca783c30c")
# Mise en forme de la base
incid_hospit$dep[incid_hospit$dep %in% c("2A", "2B")] <- "20"
transform(incid_hospit, dep = as.numeric(dep))
transform(incid_hospit, jour = as.Date(jour))
incid_hospit$jour <- as.Date(incid_hospit$jour)
incid_hospitidf <- incid_hospit[incid_hospit$dep == 75 | incid_hospit$dep == 91 |incid_hospit$dep == 92 |incid_hospit$dep == 93 |incid_hospit$dep == 94 |incid_hospit$dep == 95 |incid_hospit$dep == 77 ,]
# hosp = hospitalisation quotdienne en France
incid_hosp <- data.frame(aggregate(incid_hospit$incid_hosp, by = list(typ2 = incid_hospit$jour), sum),"France")
incid_hospidf <- data.frame(aggregate(incid_hospitidf$incid_hosp, by = list(typ2 = incid_hospitidf$jour), sum), "IdF")
colnames(incid_hosp) <- c("Date","hosp","lieu")
colnames(incid_hospidf) <- c("Date","hosp","lieu")
# data hospitalisation quotdienne en réa
incid_rea <- data.frame(aggregate(incid_hospit$incid_rea, by = list(typ2 = incid_hospit$jour), sum),"France")
incid_reaidf <- data.frame(aggregate(incid_hospitidf$incid_rea, by = list(typ2 = incid_hospitidf$jour), sum), "IdF")
colnames(incid_rea) <- c("Date","rea","lieu")
colnames(incid_reaidf) <- c("Date","rea","lieu")
#Liste des bouton plotly à masquer
listmodbar <- c("zoom2d", "pan2d", "select2d", "lasso2d", "zoomIn2d", "zoomOut2d", "autoScale2d", "resetScale2d", "hoverClosestCartesian", "hoverCompareCartesian", "zoom3d", "pan3d", "resetCameraDefault3d", "resetCameraLastSave3d", "hoverClosest3d", "orbitRotation", "tableRotation", "zoomInGeo", "zoomOutGeo", "resetGeo", "hoverClosestGeo", "sendDataToCloud", "hoverClosestGl2d", "hoverClosestPie", "toggleHover", "resetViews", "toggleSpikelines", "resetViewMapbox")
```
Data France
=======================================================================
Row
-----------------------------------------------------------------------
### Décès cumulés
```{r, echo=FALSE, warning=FALSE, message=FALSE}
# warning et message false pour ne pas affiché les alertes
# Courbe des décès cumulés
# scale_x_date : limits du 01/03 au j+2 permet l'affichage de directlab
# scale_y_continuous : affiche la dernière valeur de chaque courbe
p <- ggplot (baseIFG, aes(x=Date, y=dc, fill=Pays, colour=Pays, text = dc)) +
ggtitle("Nombre de décès COVID-19 cumulés depuis le 1er mars 2020") +
geom_line() +
scale_x_date(date_breaks = "week", date_labels = "%d %B", limits = c(as.Date("2020-03-01"),as.Date((Sys.Date())))) +
scale_y_continuous(name="Nombre de décès COVID cumulés") +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac"))
fig <- ggplotly(p, tooltip = c("colour", "Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600)) %>% layout(showlegend = FALSE)
fig
```
Row
-----------------------------------------------------------------------
### Décès journaliers
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# dc/ jours en France
# initialement geom-col décès par jour et total de mort puis nombre total non affiché par soucis d'echelle
p<- ggplot(dfj, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc)), frame = Date) +
ggtitle("Nombre de décès COVID-19 journaliers en France") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 1500)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Hospitalisations quotdiennes
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# hospit COVID
# hospit quotidiennes
p<- ggplot(NULL, aes(Date, hosp, text = paste0("Nombre d'hospitalisations : ", hosp))) +
geom_col(data = incid_hosp, alpha = 0.3, fill = "#FDAC88") +
geom_col(data = incid_hospidf, alpha = 1, fill = "#4DB4C1") +
ggtitle("Hospitalisations quotidiennes pour COVID-19 en Ile de France et\n en France") +
scale_y_continuous(name="Nombre de patients hospitalisés") +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Hopistalisations cumulées
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# hospit en cours
p<- ggplot(NULL, aes(x = Date, y = hosp, label = hosp, text = paste0("Nombre d'hospitalisations : ", hosp))) +
geom_col(data = hosp, alpha = 0.3, fill = "#FDAC88") +
geom_col(data = hospidf, alpha = 1, fill = "#4DB4C1") +
ggtitle("Patients hospitalisés pour COVID-19 en Ile de France et\n en France") +
scale_y_continuous(name="Nombre de patients hospitalisés") +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Hospitalisations quotidiennes en réa
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# hospit quotidnne en réa
p<- ggplot(NULL, aes(Date, rea, text = paste0("Nombre d'hospitalisations : ", rea))) +
geom_col(data = incid_rea, alpha = 0.3, fill = "#FDAC88") +
geom_col(data = incid_reaidf, alpha = 1, fill = "#4DB4C1") +
ggtitle("Hospitalisations quotidiennes en réanimation pour COVID-19\n en Ile de France et en France") +
scale_y_continuous(name="Nombre de patients hospitalisés") +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Hospitalisations cumulées en réa
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# Patient en réa
p<- ggplot(NULL, aes(Date, rea, text = paste0("Nombre d'hospitalisations : ", rea))) +
geom_col(data = rea, alpha = 0.3, fill = "#FDAC88") +
geom_col(data = reaidf, alpha = 1, fill = "#4DB4C1") +
ggtitle("Patients hospitalisés en réanimation pour COVID-19\n en Ile de France et en France") +
scale_y_continuous(name="Nombre de patients hospitalisés") +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Data monde
=======================================================================
Row
-----------------------------------------------------------------------
### Italie
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# dc/ jours en Italie
p<- ggplot(dij, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc))) +
ggtitle("Nombre de décès COVID-19 journaliers en Italie") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 1500)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### UK
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# dc/ jours en UK
p<- ggplot(dukj, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc))) +
ggtitle("Nombre de décès COVID-19 journaliers en Angleterre") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 1500)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### USA
```{r , echo=FALSE, warning=FALSE, message=FALSE}
# dc/ jours en US
p<- ggplot(dusj, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc))) +
ggtitle("Nombre de décès COVID-19 journaliers au USA") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 3000)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Allemagne
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# dc/ jours en Allemagne
p<- ggplot(dgj, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc))) +
ggtitle("Nombre de décès COVID-19 journaliers en Allemagne") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 1500)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Pays bas
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# dc/ jours aux pays-bas
p<- ggplot(dnj, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc))) +
ggtitle("Nombre de décès COVID-19 journaliers aux Pays-Bas") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 1500)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Row
-----------------------------------------------------------------------
### Brésil
```{r , echo=FALSE, warning=FALSE, message=FALSE }
# dc/ jours aux Brésil
p<- ggplot(dbj, aes(Date, dc, label=dc, text = paste0("Nombre de décès : ", dc))) +
ggtitle("Nombre de décès COVID-19 journaliers au Brésil") +
geom_col(fill = "#4DB4C1") +
scale_y_continuous(name="Nombre de décès COVID-19 journaliers", limits=c(0, 1500)) +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
theme(legend.position='none')
fig <- ggplotly(p, tooltip = c("Date", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600))
fig
```
Surmortalité
=======================================================================
Row
-----------------------------------------------------------------------
### Décès quotidiens
```{r , echo=FALSE, warning=FALSE, message=FALSE}
# DC par jours
DCj <- ggplot (baseDCj, aes(x=Date, y=Deces, color=Annee, label = Deces)) +
ggtitle("Mortalité journalière toutes causes confondues en France") +
geom_line () +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
scale_x_date(date_breaks = "month", date_labels = "%b", limits = c(as.Date("2020-01-01"),as.Date("2021-01-10"))) +
scale_y_continuous(name="Nombre de décès journaliers")
fig <- ggplotly(DCj, tooltip = c("Annee", "label")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600)) %>% layout(showlegend = FALSE)
fig
```
Row
-----------------------------------------------------------------------
### Décès cumulés
```{r , echo=FALSE, warning=FALSE, message=FALSE}
# DC cumulé
DCcum <- ggplot (baseDCj, aes(x=Date, y=cumsum, color=Annee, text = cumsum)) +
ggtitle("Mortalité cumulée toutes causes confondues en France") +
geom_line () +
theme_classic() + theme(plot.title = element_text(size=14, face="bold", color = "#317eac")) +
scale_x_date(date_breaks = "month", date_labels = "%b", limits = c(as.Date("2020-01-01"),as.Date("2021-01-10"))) +
scale_y_continuous(name="Nombre de décès cumulés", , limits=c(0, 700000))
fig <- ggplotly(DCcum, tooltip = c("Annee", "text")) %>% config(modeBarButtonsToRemove = listmodbar, displaylogo = FALSE, toImageButtonOptions = list(format = "png", width = 800, height = 600, filename = 'Perinat_Data')) %>% layout(showlegend = FALSE)
# fig <- ggplotly(DCcum) %>% config(displayModeBar=FALSE) %>% layout(xaxis=list(fixedrange=TRUE)) %>% layout(yaxis=list(fixedrange=TRUE))
fig
# direct.label(DCcum, method="last.bumpup")
```
Sources : 2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE & Données hospitalières relatives à l'épidémie de COVID-19 par Santé publique France & Fichier des personnes décédées, Institut National de la Statistique et des Etudes Economiques (Insee)